import {
    CREATE_ORDER
    , SUCCESS_ORDER
} from "../action-type/dingdan"

function order(state = [], {
    type,
    index,
    money,
    data
}) { //管理订单的reducer
    switch (type) {
        case CREATE_ORDER:
            let min = 1000000000000000,
                max = 999999999999999999999
            return [...state, {
                id: index,
                money,
                orderNumber: parseInt(Math.random() * Math.abs(min - max) + min),
                data,
                is:false
            }]
        case SUCCESS_ORDER:
            return state.map(item=>item.id==index?{...item,is:true}:item)
        default:
            return state
    }

}
export default order